#include <iostream>
#include <string>
#include <cmath>

bool prostoe(int x) {
    if (x % 2 == 0) {
        return x == 2;
    }
    int p = 3;
    while (p * p <= x && x % p != 0) {
        p += 2;
    }
    return p * p > x;
}

int main() {
    std::string input;
    std::getline(std::cin, input);
    std::string n = "";

    std::string words[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    for (const auto& word : input) {
        for (int i = 0; i < 10; i++) {
            if (words[i] == std::string(1, word)) {
                n += std::to_string(i);
                break;
            }
        }
    }

    int n1 = std::stoi(n);

    if (99 < n1 && n1 < 1000) {
        int f = std::abs(n1 - 2);
        int r = 2;
        int l = 3;
        while (true) {
            if (prostoe(l)) {
                int t = std::abs(n1 - l);
                if (t < f) {
                    f = t;
                    r = l;
                } else {
                    std::cout << r << std::endl;
                    break;
                }
            }
            l += 2;
        }
    } else {
        std::cout << "Wrong input" << std::endl;
    }

    return 0;
}

